package day02;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Description: shuffle 随机数据交换
 * @Author: ZYX
 * @Date: 2022/2/10 09:12
 * @Version: 1.0
 */
public class Demo07 {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // 随机分配 shuffle
        /*env.fromElements(1,2,3,4,5,7,6).setParallelism(1)
                .shuffle()
                .print("shuffle:").setParallelism(2);*/

        // 平均分配 rebalance
        /*env.fromElements(1,2,3,4,5,7,6).setParallelism(1)
                .rebalance()
                .print("rebalance:").setParallelism(2);*/

        // 各区都发送 类似广播 broadcast
        env.fromElements(1,2,3,4,5,7,6).setParallelism(1)
                .broadcast()
                .print("broadcast:").setParallelism(2);

        env.execute();
    }

}
